package com.doge.calcalbum.db

import androidx.lifecycle.LiveData
import androidx.room.*
import com.doge.calcalbum.db.model.Note
import com.doge.calcalbum.db.model.NoteTitle

@Dao
interface NoteDao {
    @Query("SELECT * FROM note ORDER BY createTime DESC")
    fun query(): LiveData<List<Note>>

    @Query("SELECT * FROM note WHERE id = :noteId")
    fun queryById(noteId: Int): Note?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(note: Note)

    @Update(entity = Note::class)
    fun updateTitle(noteTitle: NoteTitle)

    @Delete
    fun delete(note: Note)
}